<template>
  <div class="single" v-if="postList.type == 1 && postList.cover.length < 3">
    <div class="left">
      <p class="content">{{ postList.title }}</p>
      <p class="info">
        <span>{{ postList.user.nickname }}</span>
        <span>{{ postList.comment_length }}跟帖</span>
      </p>
    </div>
    <img :src="postList.cover[0].url" alt />
  </div>
  <div class="singlev" v-else-if="postList.type === 2">
    <p class="content">{{ postList.title }}</p>
    <div class="playarea">
      <img :src="postList.cover[0].url" alt />
      <div class="playicon">
        <van-icon name="play" />
      </div>
    </div>
    <p class="info">
      <span>{{ postList.user.nickname }}</span>
      <span>{{ postList.comment_length }}跟帖</span>
    </p>
  </div>
  <div
    class="singlet"
    v-else-if="postList.type === 1 && postList.cover.length >= 3"
  >
    <p class="content">{{ postList.title }}</p>
    <div class="imgs">
      <img :src="item.url" alt v-for="item in postList.cover" :key="item.id" />
    </div>
    <p class="info">
      <span>{{ postList.user.nickname }}</span>
      <span>{{ postList.comment_length }}跟帖</span>
    </p>
  </div>
</template>

<script>
export default {
  props: ["postList"],
};
</script>

<style lang="less" scoped>
body {
  overflow-x: hidden;
  overflow-y: hidden;
}
.info {
  font-size: 12px;
  padding-left: 5px;
  color: #999;
  > span:nth-of-type(1) {
    padding-right: 15px;
  }
}
.content {
  font-size: 14px;
  padding: 0px 5px;
  line-height: 24px;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  text-overflow: ellipsis;
}

.single {
  padding: 15px 0px;
  box-sizing: border-box;
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid #ccc;
  flex-wrap: wrap;
  .left {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    overflow: hidden;
  }

  img {
    width: 120/360 * 100vw;
    height: 70/360 * 100vw;
    object-fit: cover;
    padding-right: 5px;
  }
  .imgs {
    display: flex;
    padding: 10px 0 0 0;
    > img {
      flex: 1;
      padding: 0 5px;
      box-sizing: border-box;
      display: block;
    }
  }
  .video {
    width: 100%;
    height: 170/360 * 100vw;
    padding: 10px;
    box-sizing: border-box;
    > img {
      width: 100%;
      height: 100%;
    }
  }
}
.singlev {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 15px 10px;
  border-bottom: 1px solid #ccc;
  .playarea {
    margin: 10px 0;
    flex: 1;
    img {
      width: 100%;
    }
  }
  .playicon {
    position: absolute;
    display: flex;
    justify-content: center;
    align-items: center;
    left: 50%;
    top: 50%;
    width: 60px;
    height: 60px;
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);

    .van-icon {
      font-size: 50px;
      color: #fff;
    }
  }
}
.singlet {
  padding: 10px;
  border-bottom: 1px solid #ccc;
  .imgs {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100px;
    margin-bottom: 10px;
    img {
      width: 32.8%;
      height: 100%;
    }
  }
}
</style>